<!--
 * @Author: 赵天利 5450026+zhaotianli01@user.noreply.gitee.com
 * @Date: 2024-01-08 13:29:59
 * @LastEditors: 孙鹏程 2145261508@qq.com
 * @LastEditTime: 2024-03-28 16:49:11
 * @FilePath: \BZ_JT_AnQuanHuanBaoGuanLiApp\src\views\staging\commom\dangerTreatment\components\auditComponent.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <div>
    <van-form @submit="onSubmit">
      <van-field
        name="radio"
        label="审核结果"
        :required="true"
        :rules="[{ required: true, message: '请选择审核结果' }]"
      >
        <template #input>
          <van-radio-group v-model="form.auditResult" direction="horizontal">
            <van-radio name="2">审核通过</van-radio>
            <van-radio name="3">审核不通过</van-radio>
          </van-radio-group>
        </template>
      </van-field>
      <van-field
        v-model="form.auditOpinion"
        rows="2"
        autosize
        label="审核意见"
        type="textarea"
        maxlength="100"
        placeholder="请填写审核意见"
        show-word-limit
        :required="false"
      />
      <div style="margin: 0.5rem;">
        <van-button round block type="info" native-type="submit">提交</van-button>
      </div>
    </van-form>
  </div>
</template>
<script>
import { Toast } from 'vant'
import { auditEventAq, auditEventHb, auditEventXf } from '@/api/commonPage/AccidentEvents'

export default {
  components: {
  },
  data() {
    return {
      form: {
        auditResult: '',
        auditOpinion: '',
        environmentEventId: ''
      },
      apiMap: {
        '安全生产': auditEventAq,
        '环保管理': auditEventHb,
        '消防管理': auditEventXf
      }
    }
  },
  methods: {
    onSubmit() {
      const { current, environmentEventId } = this.$route.query
      this.form.environmentEventId = environmentEventId
      this.apiMap[current](this.form).then(res => {
        if (res.status === 0) {
          this.$emit('input', false)
          this.$router.push({
            path: '/staging/AccidentEvents',
            query: { ...this.$route.query, auditResult: this.form.auditResult === '2' ? '审核通过' : '审核不通过' }
          })
          Toast.success(res.data)
        }
      })
    }
  }
}
</script>
<style scoped>

</style>
